import { NavigationGuardNext, RouteLocationNormalized } from 'vue-router'
import router from './router'
import { GetNowUser } from './api/request'

router.beforeEach(
  async (
    to: RouteLocationNormalized,
    from: RouteLocationNormalized,
    next: NavigationGuardNext
  ) => {
    // 所有检查通过
    debugger
    const user = await GetNowUser()
    console.log(user)
    if (user.errCode === 0) {
      next()
    } else if (user.errCode === -1) {
      window.location.href = `https://actdota.5211game.com/LLZL623/Passport?returnurl=${window.location.href}`
    }
  }
)
